#!/usr/bin/env ruby
#^syntax detection

version ">= 1.5.1"

shell_provision_script = <<-EOF
set -x
apt-get -qy update
apt-get -qy install dnsutils
EOF

REPO = File.dirname(__FILE__)

TestLab::Container.new "simple-template" do
  distro    "ubuntu"
  release   "precise"

  template  true
end

node 'vagrant' do

  provider      TestLab::Provider::Vagrant
  provisioners  [TestLab::Provisioner::Bind]
  config        ({
    :vagrant => {
      :id       => "mytestlab-#{ENV['USER']}".downcase,
      :ip       => "192.168.255.1",
      :user     => "vagrant",
      :port     => 22,
      :cpus     => 1,
      :memory   => 512,
      :file     => Dir.pwd
    },
    :bind => {
      :domain => "default.zone"
    }
  })

  network 'testnet' do
    provisioners  [TestLab::Provisioner::Route]
    address       '100.64.0.254/24'
    bridge        :br0
  end

  container "master" do
    distro        "ubuntu"
    release       "precise"

    aa_profile  "unconfined"
    cap_drop    "thing"

    provisioners  [
      TestLab::Provisioner::Resolv,
      TestLab::Provisioner::AptCacherNG,
      TestLab::Provisioner::Apt
    ]

    user do
      username         "deployer"
      password         "deployer"
      uid              2600
      gid              2600
      public_identity  [File.join(Dir.pwd, 'test')]
      identity         [File.join(Dir.pwd, 'test.pub')]
    end

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.10/24'
      primary    true
    end

    interface do
      name       :eth1
      network_id 'testnet'
      address    '100.64.0.20/24'
    end
  end

  # SHELL PROVISIONER
  container "server-shell" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::Shell]
    config ({:script => "echo 'hello world!'"})

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.40/24'
    end
  end

  # BIND PROVISIONER
  container "server-bind" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::Bind]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.50/24'
    end
  end

  # RESOLV PROVISIONER
  container "server-resolv" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::Resolv]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.60/24'
    end
  end

  # RARING PROVISIONER
  container "server-raring" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::Raring]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.70/24'
    end
  end

  # HOSTSFILE PROVISIONER
  container "server-hostsfile" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::HostsFile]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.80/24'
    end
  end

  # APT PROVISIONER
  container "server-apt" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::Apt]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.80/24'
    end
  end

  # APTCACHERNG PROVISIONER
  container "server-aptcacherng" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::AptCacherNG]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.80/24'
    end
  end

  # ROUTE PROVISIONER
  container "server-route" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::Route]

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.80/24'
    end
  end

  # NFSMOUNT PROVISIONER
  container "server-nfsmount" do
    inherit "simple-template"

    provisioners  [TestLab::Provisioner::NFSMount]

    config ({:nfs_mounts => %w( 127.0.0.1 /share /local)})

    interface do
      name       :eth0
      network_id 'testnet'
      address    '100.64.0.80/24'
    end
  end

end
